<template>
    <div class="content">
        <div class="col-bg overview-info overview-info2 mt24">
            <div class="info-title">
                <Row type="flex" justify="space-between" class="code-row-bg">
                    <Col span="4">逾期设置</Col>
                </Row>
            </div>
            <div class="overdue-setting disflex">
                <div class="input-item-list mr10">
                    <span>逾期时长：</span>
                    <Input placeholder="请填写0以上的整数或者保留一位小数" v-model="overdueData.overdue_time" style="width: auto" />
                </div>
                <div class="input-item-list">
                    <Select v-model="overdueData.overdue_time_type" clearable placeholder="请选择">
                        <Option v-for="item1 in dateList" :value="item1.value" :key="item1.value">{{ item1.label }}</Option>
                    </Select>
                </div>
                <Button class="ml20"  @click="getSave">保存</Button>
            </div>
        </div>
    </div>
</template>
<script>
    import { overdueConfigSave,coverdueCnfigList } from '@/api/systemManage'
    export default {
        data () {
            return {
                dateId:'',
                overdueData:{
                    overdue_time:'',
                    overdue_time_type:"2"
                },
                list:[],
                dateList:[
                    {
                        value:'1',
                        label:'分钟'
                    }, {
                        value:'2',
                        label:'小时'
                    }, {
                        value:'3',
                        label:'天'
                    }, {
                        value:'4',
                        label:'周'
                    }, {
                        value:'0',
                        label:'不设置'
                    },
                ]
            }
        },
        created(){
            this.getList()
        },
        methods: {
            //获取列表
            getList(){
                coverdueCnfigList().then(res => {
                    if(res.data.length>0){
                        this.overdueData.overdue_time = res.data[0].overdue_time
                        this.overdueData.overdue_time_type = res.data[0].overdue_time_type+''
                    }
                })
            },
            getSave(){
                let that = this;
                //this.$Message.error('逾期时间只能填写0以上的整数或者保留一位小数');
                if(this.overdueData.overdue_time==''){
                    this.$Message.error('请设置逾期时间');
                    return
                }else if(this.overdueData.overdue_time_type==''||this.overdueData.overdue_time_type==undefined){
                    this.$Message.error('请选择');
                    return
                }
                if(this.overdueData.overdue_time<=0){
                    this.$Message.error('逾期时间只能填写0以上的整数或者保留一位小数');
                    return;
                }
                console.log(this.overdueData.overdue_time)
                overdueConfigSave(this.overdueData).then(res => {
                    if(res.errno==0) {
                        this.$Message.info('设置成功')
                    }else if(res.errno==1001){
                        this.$Message.error(res.errmsg)
                    }
                })
            },
        }
    }
</script>
